#include<iostream>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
struct node
{
	int l, r;
}s[N];
int n;
int cmp(node a, node b)
{
	return a.r < b.r;
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		s[i] = { a,b };
	}
	sort(s, s + n, cmp);
	int ans = 0;
	int temp = 1e9;
	for (int i = 0; i < n; i++) {
		if (temp == 1e9 || temp < s[i].l) {
			ans++;
			temp = s[i].r;
		}
	}
	cout << ans << endl;
	return 0;
}